/*
 * Copyright (c) 2007 jNetX.
 * http://www.jnetx.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * jNetX. You shall not disclose such Confidential Information and
 * shall use it only in accordance with the terms of the license
 * agreement you entered into with jNetX.
 *
 * $Id$
 */
package com.jnetx.javax.sip.header;

import javax.sip.header.ExtensionHeader;
import java.text.ParseException;

/**
 * @author <a href="mailto:dparhonin@jnetx.ru">Dmitry Parhonin</a>
 * @version $Revision$
 */
public class ExtensionHeaderImpl implements ExtensionHeader {
    private String name;
    private String value;

    ExtensionHeaderImpl(String name) {
        this.name = name;
    }

    ExtensionHeaderImpl(String name, String value) {
        this.name = name;
        this.value = value;
    }

    /**
     * Sets the value parameter of the ExtensionHeader.
     *
     * @param value the new value of the ExtensionHeader
     * @throws java.text.ParseException which signals that an error has been reached
     *                                  unexpectedly while parsing the value parameter.
     */
    public void setValue(String value) throws ParseException {
        this.value = value;
    }

    /**
     * Gets the value of the ExtensionHeader.
     *
     * @return the string of the value parameter.
     */
    public String getValue() {
        return value;
    }

    /**
     * Gets the unique string name of this Header. A name constant is defined in
     * each individual Header identifying each Header.
     *
     * @return the name of this specific Header
     */
    public String getName() {
        return name;
    }

    /**
     * Creates and returns a deep copy of the Header. This methods must ensure a
     * deep copy of the Header, so that when a message is cloned the Header can
     * be modified without effecting the original Header in the message. This
     * provides useful functionality for proxying Requests and Responses, for
     * example:
     * <ul>
     * <li>Recieve a message.
     * <li>Create a deep clone of the message and headers.
     * <li>Modify necessary headers.
     * <li>Proxy the message using the send methods on the SipProvider.
     * </ul>
     * This method overrides the clone method in java.lang.Object.
     *
     * @return a deep copy of Header
     */
    public Object clone() {
        final ExtensionHeaderImpl header = new ExtensionHeaderImpl(this.name);
        header.value = this.value;
        return header;
    }

    public String toString() {
        return name + ':' + ' ' + value;
    }
}
/*
 * $Log$
 */